home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-22 | 2.6 KB | 94 lines | [TEXT/CWIE] |
- # include "Shell.h"
-
- extern Boolean gDoneFlag;
-
-
- /****************************************************
- Quickdraw Things...
- *****************************************************/
-
-
- /*------------------------------------------------------------------------
- NewPixImage() Creates pix image and inits the fields of the pixmap...
- ------------------------------------------------------------------------*/
-
- Boolean NewPixImage(PixMapHandle ThePix, Rect *TheRect, short dpth)
- {
- Ptr ThePtr;
- long Offrowbytes, ptrsize;
-
- Offrowbytes =(((dpth * (TheRect->right - TheRect->left)) + 15) / 16) * 2;
- ptrsize = (TheRect->bottom - TheRect->top) * Offrowbytes;
- ThePtr = NewPtr(ptrsize);
- if(MemError() != noErr)
- return(false);
-
- (**ThePix).baseAddr = ThePtr;
- (**ThePix).rowBytes = Offrowbytes + 0x8000;
- (**ThePix).bounds = *TheRect;
- (**ThePix).pixelSize = dpth;
- (**ThePix).cmpCount = 1;
- (**ThePix).cmpSize = dpth;
- return(true);
- }
-
-
- /*------------------------------------------------------------------------
- NewBitMap() Creates bit image and inits the fields of the bitmap...
- ------------------------------------------------------------------------*/
-
- Boolean NewBitMap(BitMap *TheMap, Rect *TheRect)
- {
- long rb;
- Ptr ba;
-
- rb = ((TheRect->right - TheRect->left + 15) / 16) * 2;
- ba = NewPtr(rb * (TheRect->bottom - TheRect->top));
- if( MemError() == noErr)
- {
- TheMap->rowBytes = rb;
- TheMap->baseAddr = ba;
- TheMap->bounds = *TheRect;
- return(true);
- }
- else
- return(false);
- }
-
- /*-------------------------------------------------------------------------
- CenterRect() Centers theRect over thePt...
- --------------------------------------------------------------------------*/
- void CenterRect(Rect *theRect, Point *thePt)
- {
- /* First home theRect... */
-
- OffsetRect(theRect, -theRect->left, -theRect->top);
-
- /* ...then center it over thePt */
-
-
- thePt->h = thePt->h - (theRect->right / 2);
- thePt->v = thePt->v - (theRect->bottom / 2);
- OffsetRect(theRect, thePt->h, thePt->v);
- }
-
- /*-------------------------------------------------------------------------
- Center() Returns the center of the rect
- --------------------------------------------------------------------------*/
- Point Center(Rect *theRect)
- {
- Point pt;
-
- pt.h = theRect->left + ((theRect->right - theRect->left) / 2);
- pt.v = theRect->top + ((theRect->bottom - theRect->top) / 2);
- return(pt);
- }
-
- // Since we can't call GetMHandle to access the menu handle, we have to
- // look at the data stored in the control record
- MenuHandle GetPopUpMenuHandle(ControlHandle thisControl)
- {
- popupPrivateDataHdl theMenuData = (popupPrivateDataHdl)(*thisControl)->contrlData;
- return((*theMenuData)->mHandle);
- }
-